<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>美发开单</title>
<script type="text/javascript">
var $qr = $('#doc-qrcode');
$qr.empty().qrcode({
	  text: "${codeUrl}",
	  width: 230,
	  height: 230,
	});
var timeout = setInterval(function() {
	payQuery("0");
},2000);

$("#over-btn").on("click",function(){
	clearInterval(timeout);
	payQuery("1");
});
function payQuery(type){
	var orderNo=$("#orderNo").val();
	var orderInfoId=$("#orderInfoId").val();
	var vipId=$("#vipId").val();
	var data = "orderNo="+orderNo;
	if(type=="1"){
		data = data+"&payOver=true";
	}
	$.ajax({
		type : 'POST',
        url: "${ctx}/weixin/employee/payResult",
        dataType: "json",
        data:data,
        success: function (data) {
            if (data.success) {
            	clearInterval(timeout);
            	alert("支付成功");
            	window.location.href="${ctx}/weixin/employee/vipInfo?vipId="+vipId+"&orderInfoId="+orderInfoId;
            }else{
            	if(data.params&&data.params.error){
            		Comm.msg(data.msg);
            		clearInterval(timeout);
            	}
            	if(type=="1"){
            		Comm.msg(data.msg);
                	setTimeout(function() {
                		window.location.href="${ctx}/weixin/employee/orderPay/"+orderInfoId;
    				}, 2000);
            	}
            }
        },
        error: function () {
        	Comm.msg("网络连接失败，请稍后重试");
        	clearInterval(timeout);
        }
    });
}
</script>
</head>
<body>
<input id="orderNo" name="orderNo" type="hidden" value="${orderNo}"></input>
<input id="orderInfoId" name="orderInfoId" type="hidden" value="${orderInfoId}"></input>
<input id="vipId" name="vipId" type="hidden" value="${vipId}"></input>
	<ul class="am-avg-sm-1 app-qrcode-con am-text-center">
		<li>扫一扫付款（元）</li>
		<li><h1 class="am-text-blue am-margin-bottom-0">${amount}</h1></li>
		<li><div id="doc-qrcode" class="am-text-center"></div></li>
		<li>打开手机微信&nbsp;&nbsp;扫一扫来付款</li>
		<li><button id="over-btn" class="am-btn am-btn-landiao am-radius am-padding-horizontal-lg" type="button">支付完成</button></li>
	</ul>
</body>
</html>
